<template>
    <div class="picture2">
        <el-card style="position: relative; margin: 100px auto; background-color:rgba(213,210,210,0.55);
             width: 500px; height: 600px; padding: 20px; border-radius: 10px;">
            <el-form label-width="80px" size="small">
                <el-form-item label="头像">
                    <div style="margin-left: 70px">
                        <img src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"/>
                    </div>
                </el-form-item>
               <!-- <el-upload
                        style="text-align: center ;padding-bottom: 10px"
                        class="avatar-uploader"
                        action="http://localhost:9099/file/upload"
                        :show-file-list="false"
                        :on-success="handleAvatarSuccess"
                >
                    <img v-if="form.avatarurl" :src="form.avatarurl" class="avatar">
                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                </el-upload>-->

                <el-form-item label="用户名" >
                    <el-input v-model="form.username" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="用户id">
                    <el-input v-model="form.userid" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="性别" >
                    <el-input v-model="form.gender" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="电话" >
                    <el-input v-model="form.tel" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="会员等级" >
                    <el-input v-model="form.membership" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="账户余额" >
                    <el-input v-model="form.account" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item style="text-align: center">
                    <el-button type="primary" @click="save">确 定</el-button>
                </el-form-item>
            </el-form>
        </el-card>
    </div>
</template>

<script>
    export default {
        name: "Person",
        data(){
            return{

                form: {},
                user: localStorage.getItem("user") ? JSON.parse(localStorage.getItem("user")) : {}  //从登录信息中取username
            }
        },
        created() {
            this.request.get("/user/username/" + this.user.username).then(res => {
                if(res.code === '200'){
                    this.form = res.data
                }
            })
        },
        methods: {
            save() {
                this.request.post("/user",this.form).then( res => {
                    if(res.data){
                        this.$message.success("保存成功")
                    }else{
                        this.$message.error("保存失败")
                    }
                })
            },
            /*handleAvatarSuccess(res){
                console.log("这里是个人信息")
                console.log(res)
                this.form.avatarurl = res

            }*/
        }
    }
</script>

<style>
    .picture2 {
        height: 100vh;
        background: url("http://localhost:9099/file/73e921b2a67849c8ab712978e28ec7bd.png");
        background-size: cover; /* 使图片平铺满整个浏览器（从宽和高的最大需求方面来满足，会使某些部分无法显示在区域中） */
        z-index: -1;
        overflow: hidden;
    }
    /*    .avatar-uploader .el-upload {
            border: 1px dashed #d9d9d9;
            border-radius: 6px;
            cursor: pointer;
            position: relative;
            overflow: hidden;
        }
        .avatar-uploader .el-upload:hover {
            border-color: #409EFF;
        }
        .avatar-uploader-icon {
            font-size: 28px;
            color: #8c939d;
            width: 178px;
            height: 178px;
            line-height: 178px;
            text-align: center;
        }
        .avatar {
            width: 178px;
            height: 178px;
            display: block;
        }*/


</style>